/********************************************************************************
 *      Copyright:  (C) 2022 guoyi<675088383@qq.com>
 *                  All rights reserved.
 *
 *       Filename:  sqlite_db.h
 *    Description:  This head file 
 *
 *        Version:  1.0.0(11/12/21)
 *         Author:  guoyi<675088383@qq.com>
 *      ChangeLog:  1, Release initial version on "22/2/26 13:55:01"
 *                 
 ********************************************************************************/

#ifndef  _SQLITE_DB_H_
#define  _SQLITE_DB_H_

#define  SQL_COMMAND_LEN     256

#include "sqlite3.h"

typedef struct sample_data_s
{
    char            sn[16];
    char            time[32];
    float           temper;
} sample_data_t;

extern int db_init(sqlite3 **db, const char *db_name, const char *tb_name);

extern int db_count_record(sqlite3 *db, const char *tb_name);

extern int db_push_record(sqlite3 *db, const char *tb_name, sample_data_t *data, int bytes);

extern int db_get_record(sqlite3 *db, const char *tb_name, sample_data_t *data, int bytes);

extern int db_del_1stRecord(sqlite3 *db, const char *tb_name);

extern int db_query_record(sqlite3 *db, char *sql);

extern void db_term(sqlite3 *db);

#endif
